package com.yangrui.app.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.yangrui.app.group.InsertGroup;
import com.yangrui.app.group.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "用户实体类", description = "用户实体类")
@JsonIgnoreProperties(value = {"handler"})
public class User {

    @ApiModelProperty(value = "用户id", name = "id", example = "1")
    @Null(message = "用户id必须为空" , groups = InsertGroup.class)
    @NotNull(message = "用户id不能为空" , groups = UpdateGroup.class)
    private Integer id;
    @ApiModelProperty(value = "用户名", name = "username", example = "admin")
    @NotNull(message = "用户名不能为空" , groups = {InsertGroup.class , UpdateGroup.class})
    private String username;
    @ApiModelProperty(value = "密码", name = "password", example = "123456")
    @NotNull(message = "密码不能为空" , groups = {InsertGroup.class , UpdateGroup.class})
    private String password;
    @ApiModelProperty(value = "真实姓名", name = "realName", example = "admin")
    @JsonProperty("real-name")
    @NotNull(message = "真实姓名不能为空" , groups = {UpdateGroup.class})
    private String realName;
    @ApiModelProperty(value = "性别", name = "gender",example = "1")
    @NotNull(message = "性别不能为空" ,groups = {UpdateGroup.class})
    private  Integer gender;
    @ApiModelProperty(value = "头像", name = "avatar")
    @NotNull(message = "头像不能为空" , groups = {UpdateGroup.class})
    private String avatar;
    @ApiModelProperty(value = "电话", name = "phone",example = "11111111111")
    @NotNull(message = "电话不能为空" , groups = {InsertGroup.class , UpdateGroup.class})
    private String phone;
    @ApiModelProperty(value = "创建时间", name = "createTime")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Null(message = "创建时间必须为空" , groups = {InsertGroup.class , UpdateGroup.class})
    private Date createTime;
}
